package org.easy.tool.controller;

import org.easy.tool.common.R;
import org.easy.tool.service.IProblemKnowledge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Valley
 * @since 2024-09-04 22:51:14
 */
@RestController
@RequestMapping("/problemKnowledge")
public class ProblemKnowledgeController {

    @Autowired
    IProblemKnowledge problemKnowledgeService;

    @RequestMapping("batchAddByProblemId")
    public R batchAddByProblemId(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        return R.ok(problemKnowledgeService.batchAddByProblemId(data));
    }

    @RequestMapping("addProblemKnowledge")
    public R addProblemKnowledge(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        String problemId = (String) data.get("problemId");
        String knowledgeId = (String) data.get("knowledgeId");
        return R.ok(problemKnowledgeService.addProblemKnowledge(problemId, knowledgeId));
    }

    @RequestMapping("getProblemKnowledgeList")
    public R getProblemKnowledgeList(@RequestBody(required = false) LinkedHashMap data) throws Exception {
        return R.ok(problemKnowledgeService.getProblemKnowledgeList(data));
    }

    @RequestMapping("editProblemKnowledge")
    public R editProblemKnowledge(@RequestBody(required = false) LinkedHashMap data) throws Exception {
        return R.ok(problemKnowledgeService.editProblemKnowledge(data));
    }

    @RequestMapping("getProblemList")
    public R getProblemList(@RequestBody(required = false) LinkedHashMap data) throws Exception {
        return R.ok(problemKnowledgeService.getProblemList(data));
    }

    @RequestMapping("getSubjectWithProblem")
    public R getSubjectWithProblem(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        return R.ok(problemKnowledgeService.getSubjectWithProblem(data));
    }

    @RequestMapping("exam")
    public R exam(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        return R.ok(problemKnowledgeService.exam(data));
    }

    @RequestMapping("test1")
    public R demo(@RequestBody(required = false)LinkedHashMap data) throws Exception {
        return R.ok(problemKnowledgeService.test1());
    }

}
